//
//  ForumReplyTableCell.m
//  Blank
//
//  Created by 周星宇 on 15/9/28.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "ForumReplyTableCell.h"

@implementation ForumReplyTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[UIView alloc] init];
        self.title = [[UILabel alloc] init];
        self.author = [[UILabel alloc] init];
        self.readNumber = [[UILabel alloc] init];
        self.comment = [[UILabel alloc] init];
        [self.contentView addSubview:self.backView];
        [self.backView addSubview:self.title];
        [self.backView addSubview:self.author];
        [self.backView addSubview:self.readNumber];
        [self.backView addSubview:self.comment];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.backView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 100 * Height);
    self.title.frame = CGRectMake(20 * Windth, 10 * Height, self.contentView.frame.size.width - 40 * Windth, 60 * Height);
    self.title.font = [UIFont systemFontOfSize:17];
    self.title.numberOfLines = 0;
    self.author.frame = CGRectMake(20 * Windth, 70 * Height, 100 * Windth, 30 * Height);
    self.author.font = [UIFont systemFontOfSize:12];
    self.readNumber.frame = CGRectMake(200 * Windth, 70 * Height, 85 * Windth, 30 * Height);
    self.readNumber.font = [UIFont systemFontOfSize:12];
    self.comment.frame = CGRectMake(285 * Windth, 70 * Height, 80 * Windth, 30 * Height);
    self.comment.font = [UIFont systemFontOfSize:12];
    
    if ([NightModel getColorModel]) {
        self.contentView.backgroundColor = [UIColor grayColor];
        self.backView.backgroundColor = [UIColor grayColor];
        self.title.backgroundColor = [UIColor grayColor];
        self.title.textColor = [UIColor whiteColor];
        self.author.textColor = [UIColor whiteColor];
        self.author.backgroundColor = [UIColor grayColor];
        self.readNumber.backgroundColor = [UIColor grayColor];
        self.readNumber.textColor = [UIColor whiteColor];
        self.comment.backgroundColor = [UIColor grayColor];
        self.comment.textColor = [UIColor whiteColor];
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backView.backgroundColor = [UIColor colorWithRed:238 / 255.0 green:238 / 255.0 blue:238 / 255.0 alpha:0.7];
        self.title.textColor = [UIColor grayColor];
        self.title.backgroundColor = [UIColor colorWithRed:238 / 255.0 green:238 / 255.0 blue:238 / 255.0 alpha:0.7];
        self.author.textColor = [UIColor grayColor];
        self.author.backgroundColor = [UIColor colorWithRed:238 / 255.0 green:238 / 255.0 blue:238 / 255.0 alpha:0.7];
        self.readNumber.textColor = [UIColor grayColor];
        self.readNumber.backgroundColor = [UIColor colorWithRed:238 / 255.0 green:238 / 255.0 blue:238 / 255.0 alpha:0.7];
        self.comment.textColor = [UIColor grayColor];
        self.comment.backgroundColor = [UIColor colorWithRed:238 / 255.0 green:238 / 255.0 blue:238 / 255.0 alpha:0.7];
    }
}

- (void)setReplyModel:(ForumReplyModel *)replyModel{
    self.title.text = replyModel.subject;
    self.author.text = replyModel.author;
    NSString *read = [NSString stringWithFormat:@"%@次阅读", replyModel.views];
    self.readNumber.text = read;
    NSString *replies = [NSString stringWithFormat:@"%@次评论", replyModel.replies];
    self.comment.text = replies;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
